package com.ruoyi.aqi.controller;

import com.ruoyi.aqi.mapper.StatisticMapper;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import static com.ruoyi.common.core.domain.AjaxResult.success;

/**
 * TODO: 修改类描述
 *
 * @author Houtaroy
 */
@Api(tags = "统计查询")
@RestController
@RequestMapping("/aqi/statistic")
public class StatisticController {

    @Autowired
    private StatisticMapper statisticMapper;

    /**
     * 获取AQI天详细信息
     */
    @ApiOperation("地区每年空气质量等级天数")
    @ResponseBody
    @Anonymous
    @GetMapping(value = "/station-rank-days")
    public AjaxResult stationRankDay(String station) {
        return success(statisticMapper.stationRankDay(station));
    }

    /**
     * 获取AQI天详细信息
     */
    @ApiOperation("地区某年空气质量等级天数")
    @ResponseBody
    @Anonymous
    @GetMapping(value = "/station-year-rank-days")
    public AjaxResult stationRankDay(String station, Integer year) {
        return success(statisticMapper.stationYearRankDay(station, year));
    }

    /**
     * 获取AQI天详细信息
     */
    @ApiOperation("地区某年AQI")
    @ResponseBody
    @Anonymous
    @GetMapping(value = "/station-year-aqi")
    public AjaxResult stationYearAQI(String station, Integer year) {
        return success(statisticMapper.stationYearAQI(station, year));
    }

    /**
     * 获取AQI天详细信息
     */
    @ApiOperation("地区某年IAQI")
    @ResponseBody
    @Anonymous
    @GetMapping(value = "/station-year-iaqi")
    public AjaxResult stationYearIAQI(String station, Integer year) {
        return success(statisticMapper.stationYearIAQI(station, year));
    }

    /**
     * 获取AQI天详细信息
     */
    @ApiOperation("每地区平均AQI")
    @ResponseBody
    @Anonymous
    @GetMapping(value = "/aqi")
    public AjaxResult aqi() {
        return success(statisticMapper.aqi());
    }

    /**
     * 获取AQI天详细信息
     */
    @ApiOperation("每地区每年AQI")
    @ResponseBody
    @Anonymous
    @GetMapping(value = "/aqi-year")
    public AjaxResult aqiYear() {
        return success(statisticMapper.aqiYear());
    }

    /**
     * 获取AQI天详细信息
     */
    @ApiOperation("每地区空气质量等级天数")
    @ResponseBody
    @Anonymous
    @GetMapping(value = "/rank-day")
    public AjaxResult rankDay() {
        return success(statisticMapper.rankDay());
    }
}
